using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_MainPage {
		#region Fields
		private int iD;
		private int main_pgID;
		private string main_pgName;
		private string main_pgTitle;
		private int main_pgPriority;
		private DateTime main_dateModified = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
		private int languageID;
		private int menuType;
		private string uRL;
		private string cSSName;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_MainPage class.
		/// </summary>
		public TF_MainPage() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_MainPage class.
		/// </summary>
		public TF_MainPage(int main_pgID, string main_pgName, string main_pgTitle, int main_pgPriority, DateTime main_dateModified, int languageID, int menuType, string uRL, string cSSName) {
			this.main_pgID = main_pgID;
			this.main_pgName = main_pgName;
			this.main_pgTitle = main_pgTitle;
			this.main_pgPriority = main_pgPriority;
			this.main_dateModified = main_dateModified;
			this.languageID = languageID;
			this.menuType = menuType;
			this.uRL = uRL;
			this.cSSName = cSSName;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_MainPage class.
		/// </summary>
		public TF_MainPage(int iD, int main_pgID, string main_pgName, string main_pgTitle, int main_pgPriority, DateTime main_dateModified, int languageID, int menuType, string uRL, string cSSName) {
			this.iD = iD;
			this.main_pgID = main_pgID;
			this.main_pgName = main_pgName;
			this.main_pgTitle = main_pgTitle;
			this.main_pgPriority = main_pgPriority;
			this.main_dateModified = main_dateModified;
			this.languageID = languageID;
			this.menuType = menuType;
			this.uRL = uRL;
			this.cSSName = cSSName;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the ID value.
		/// </summary>
		public int ID {
			get { return iD; }
			set { iD = value; }
		}
		
		/// <summary>
		/// Gets or sets the Main_pgID value.
		/// </summary>
		public int Main_pgID {
			get { return main_pgID; }
			set { main_pgID = value; }
		}
		
		/// <summary>
		/// Gets or sets the Main_pgName value.
		/// </summary>
		public string Main_pgName {
			get { return main_pgName; }
			set { main_pgName = value; }
		}
		
		/// <summary>
		/// Gets or sets the Main_pgTitle value.
		/// </summary>
		public string Main_pgTitle {
			get { return main_pgTitle; }
			set { main_pgTitle = value; }
		}
		
		/// <summary>
		/// Gets or sets the Main_pgPriority value.
		/// </summary>
		public int Main_pgPriority {
			get { return main_pgPriority; }
			set { main_pgPriority = value; }
		}
		
		/// <summary>
		/// Gets or sets the Main_dateModified value.
		/// </summary>
		public DateTime Main_dateModified {
			get { return main_dateModified; }
			set { main_dateModified = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanguageID value.
		/// </summary>
		public int LanguageID {
			get { return languageID; }
			set { languageID = value; }
		}
		
		/// <summary>
		/// Gets or sets the MenuType value.
		/// </summary>
		public int MenuType {
			get { return menuType; }
			set { menuType = value; }
		}
		
		/// <summary>
		/// Gets or sets the URL value.
		/// </summary>
		public string URL {
			get { return uRL; }
			set { uRL = value; }
		}
		
		/// <summary>
		/// Gets or sets the CSSName value.
		/// </summary>
		public string CSSName {
			get { return cSSName; }
			set { cSSName = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_MainPages table.
		/// </summary>
		public void Insert() {
			iD = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_MainPagesInsert", main_pgID, main_pgName, main_pgTitle, main_pgPriority, main_dateModified, languageID, menuType, uRL, cSSName));
		}
		
		/// <summary>
		/// Updates a record in the TF_MainPages table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_MainPagesUpdate", iD, main_pgID, main_pgName, main_pgTitle, main_pgPriority, main_dateModified, languageID, menuType, uRL, cSSName);
		}
		
		/// <summary>
		/// Deletes a record from the TF_MainPages table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_MainPagesDelete", iD);
		}
		
		/// <summary>
		/// Selects a single record from the TF_MainPages table.
		/// </summary>
		public static TF_MainPage Select(int iD) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_MainPagesSelect", iD)) {
				if (dataReader.Read()) {
					return MakeTF_MainPage(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_MainPages table.
		/// </summary>
		public static List<TF_MainPage> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_MainPagesSelectAll")) {
				List<TF_MainPage> tF_MainPageList = new List<TF_MainPage>();
				while (dataReader.Read()) {
					TF_MainPage tF_MainPage = MakeTF_MainPage(dataReader);
					tF_MainPageList.Add(tF_MainPage);
				}
				return tF_MainPageList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_MainPages class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_MainPage MakeTF_MainPage(SqlDataReader dataReader) {
			TF_MainPage tF_MainPage = new TF_MainPage();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_MainPage.ID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_MainPage.Main_pgID = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_MainPage.Main_pgName = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_MainPage.Main_pgTitle = dataReader.GetString(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_MainPage.Main_pgPriority = dataReader.GetInt32(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_MainPage.Main_dateModified = dataReader.GetDateTime(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_MainPage.LanguageID = dataReader.GetInt32(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_MainPage.MenuType = dataReader.GetInt32(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_MainPage.URL = dataReader.GetString(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_MainPage.CSSName = dataReader.GetString(9);
			}

			return tF_MainPage;
		}
		#endregion
	}
}
